{extend name="base"/}
{block name="title"}
地址编辑
{/block}
{block name="css"}
<link rel="stylesheet" href="__MOBILE__/css/wangStyle.css"/>
<style>
    body{
        background: #fff;
    }
</style>
{/block}
{block name="content"}
<div class="head">
    <div class="head_left"><a href="javascript:history.go(-1);"><img src="__MOBILE__/images/true.png" alt=""></a></div>
    <div class="head_con">地址编辑</div>
    <div class="head_right"></div>
</div>
<div class="editor">
    <input type="hidden" name="id" value="{$res.id}"/>
    <div>
        <p>姓名</p>
        <input type="text" placeholder="请输入姓名" name="name" value="{$res.username}">
    </div>
    <div>
        <p>手机号</p>
        <input type="text" placeholder="请输入手机号" name="phone" value="{$res.mobile}">
    </div>
    <div>
        <p>详细地址</p>
        <textarea cols="30" rows="10" id="addr" placeholder="请输入详细地址" class="address">{$res.address}</textarea>
    </div>
    <div class="exitBtn">保&nbsp;&nbsp;存</div>
</div>
{/block}
{block name="js"}
<script>
    $(function () {
        $('.exitBtn').click(function () {
            var username = $("input[name='name']").val();console.log(username);
            var mobile = $("input[name='phone']").val();console.log(mobile);
            var address = $(".address").val();
            var id = $("input[name='id']").val();
            if(username == '' || mobile == '' || address == ''){
                layer.msg('请填写完整信息');
                return false;
            }else{
                 if(id == null || id === undefined || id == ''){
                    $.post('/langjinmobile/Merchandise/addresseditor',{'username':username,'mobile':mobile,'address':address},function(data){
                        console.log('sss');
                        console.log(data);
                        if(data.status == 1){
                            layer.msg(data.msg, {
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                window.location.href = "/langjinmobile/merchandise/addmar";
                            });
                        }else{
                            layer.msg(data.msg);
                        }
                    })
                }else{
                    $.post('/langjinmobile/Merchandise/edit_address',{'username':username,'mobile':mobile,'address':address,'id':id},function(data){
                        console.log(data);
                        if(data.status == 1){
                            layer.msg(data.msg, {
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                window.location.href = "/langjinmobile/Merchandise/addmar";
                            });
                        }else{
                            layer.msg(data.msg);
                        }
                    })
                } 
            }
        })
    })
</script>
{/block}